package com.example.dao;

import com.example.entity.Orders;
import com.example.entity.Users;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface OrdersMapper {


    @Select("select * from orders")
    ArrayList<Orders> queryAll();

    @Delete("delete from orders where oId = #{id}")
    int deleteById(Integer id);

    @Select("select * from orders where oID = #{id}")
    Orders findById(Integer id);

    @Update("UPDATE orders SET " +
            "oId = #{orders.oid}," +
            "uId = #{orders.uid}, " +
            "oTime = #{orders.otime}," +
            "oTotal = #{orders.ototal}" +
            "WHERE oId = #{orders.oid}")
    int update(@Param("orders") Orders orders);

    @Insert("INSERT INTO orders" +
            "(oID,uID,oTime,oTotal)" +
            "VALUES(#{orders.oid},#{orders.uid},#{orders.otime},#{orders.ototal})")
    int insert(@Param("orders") Orders orders);

}
